jQuery.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
		{
			return {
				"iStart":         oSettings._iDisplayStart,
				"iEnd":           oSettings.fnDisplayEnd(),
				"iLength":        oSettings._iDisplayLength,
				"iTotal":         oSettings.fnRecordsTotal(),
				"iFilteredTotal": oSettings.fnRecordsDisplay(),
				"iPage":          oSettings._iDisplayLength === -1 ?
					0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
				"iTotalPages":    oSettings._iDisplayLength === -1 ?
					0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
			};
		};

	
	function dataTable(data,path) {
		var oLanguage = data.split(",");

		$("#sitedata").dataTable( {
			"oLanguage": {
	            "oPaginate": {
	                          "sFirst": oLanguage[0],// ปุ่มกลับมาหน้าแรก
	                          "sLast": oLanguage[1],//ปุ่มไปหน้าสุดท้าย
	                          "sNext": oLanguage[2], //ปุ่มหน้าถัดไป
	                          "sPrevious": oLanguage[3] // ปุ่ม กลับ
	                        	  },
	             "sLengthMenu": oLanguage[4],  
	             "sZeroRecords": oLanguage[5], 
	             "sInfo": oLanguage[6],
	             "sEmptyTable": oLanguage[7],
	             "sLoadingRecords": oLanguage[8],  
	             "sProcessing": oLanguage[9],
	             "sInfoEmpty": oLanguage[10],
	             "sInfoFiltered": oLanguage[11],  
	             "sSearch": oLanguage[12]
	        },
			"fnRowCallback" : function(nRow, aData, iDisplayIndex){
                $("td:first", nRow).html(iDisplayIndex +1);
               return nRow;
            },
	        "bProcessing": true,
//	        "bServerSide": true,
//	        "sort": "position",
	        //bStateSave variable you can use to save state on client cookies: set value "true" 
	        "bStateSave": false,
	        //Default: Page display length
	        "iDisplayLength": 10,
	        //We will use below variable to track page number on server side(For more information visit: http://legacy.datatables.net/usage/options#iDisplayStart)
	        "iDisplayStart": 0,
	        "fnDrawCallback": function () {
	            //Get page numer on client. Please note: number start from 0 So
	            //for the first page you will see 0 second page 1 third page 2...
	            //Un-comment below alert to see page number
	        	//alert("Current page number: "+this.fnPagingInfo().iPage);    
	        },         
	        "sAjaxSource": "site/siteDataTables",
	        "aoColumns": [
				{ "mData": null,sClass: "center", sWidth: '10%'},
				{ "mData": "vaSiteId",sClass: "center", sWidth: '10%' },
				{ "mData": "vaSiteName",sClass: "left", sWidth: '40%'  },
				{ "mData": null,"mRender" :function ( data, type, full ) {
					if (full.vaStatus=='A'){
						return "Active";
					} else if ( full.vaStatus == 'I'){
						return "Inactive";
					}
				    
			    	},sClass: "center", sWidth: '20%' },
				{ "mData": null,"mRender": function ( data, type, full ) {
					var poObject = [full.vaSiteId,full.vaSiteName,full.vaStatus];
					
				    return 	"<span class='label label-editClick' onclick=\"editSiteData('"+poObject+"')\"><i class='fa fa-edit'></i> Edit </span>";
				    }
				, sWidth: '20%',sClass: "center"},
	        ]} 
		);
		
		$('#chk-all').click(function()	{
			if($(this).is(':checked'))	{
				$('#responsiveTable').find('.chk-row').each(function()	{
					$(this).prop('checked', true);
					$(this).parent().parent().parent().addClass('selected');
				});
			}
			else	{
				$('#responsiveTable').find('.chk-row').each(function()	{
					$(this).prop('checked' , false);
					$(this).parent().parent().parent().removeClass('selected');
				});
			}
		});
	}

	function editSiteData(data){
		var paSiteObject = data.split(",");
		$("#vaSiteId").val(paSiteObject[0]);
		document.getElementById('vaSiteId').readOnly  = true;
		$("#vaSiteName").val(paSiteObject[1]);
		$("#vaStatus").val(paSiteObject[2]);
		$("#processType").val("updateSite");
	}
